package com.example.demo.cfg;

import com.example.demo.interceptor.SecurityInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/*
*
* */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {
    /*
    * 登录session_key
    * */
    public final static String SESSION_KEY = "token";

    public SecurityInterceptor getSecurityInterceptor(){
        return new SecurityInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration addInterceptor = registry.addInterceptor(getSecurityInterceptor());

        //排除配置
        addInterceptor.excludePathPatterns("/error");
        addInterceptor.excludePathPatterns("/lgtout/login**");

        addInterceptor.addPathPatterns("/**");

    }
}
